﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Diagnostics;

public partial class OutSourcingPerfiles : System.Web.UI.Page
{
     //creamos el dataset que contendra las tablas
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["iduser"] == null || Session["iduser"].ToString() == "0")
            {
                Response.Redirect("index.aspx");
            }
            else
            {
                //llenamos el dataset con los datos de la tablas de Outsourcing
                Outs.Outsourcing a = new Outs.Outsourcing();
                ds = a.ConsultaOutSourcing();
            }
        }
    }
    
   
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            //creamos el objeto tabla para llenar una nueva fila
            DataTable TOut = ds.Tables["Perfiles"];
            DataRow row = TOut.NewRow();
            //ingresamos los datos de la fila
            row["IdPerfiles"] = ds.Tables["Perfiles"].Rows.Count + 1;
            row["Descripcion"] = TxtOutDescrip.Text;
            row["IdOutsourcing"] = 1;

            ds.Tables["Perfiles"].Rows.Add(row);

            Outs.Outsourcing cl = new Outs.Outsourcing();
            cl.DatoPerfil(ds);
            ds.AcceptChanges();
        }
        catch (Exception ex)
        {


            EventLog LogErr = new EventLog();
            if (!EventLog.SourceExists("WebContrataci"))
            {
                EventLog.CreateEventSource("WebContrataci", "Application");
                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
            }
            else
            {

                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString());
            }
        }
    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            //creamos el objeto tabla para llenar una nueva fila
            DataTable TOut = ds.Tables["TiposIndustria"];
            DataRow row = TOut.NewRow();
            //ingresamos los datos de la fila
            row["IdIndustria"] = ds.Tables["TiposIndustria"].Rows.Count + 1;
            row["Nombre"] = TxtTipIndustria.Text;


            ds.Tables["TiposIndustria"].Rows.Add(row);

            Outs.Outsourcing cl = new Outs.Outsourcing();
            cl.DatoTipoIndustria(ds);
            ds.AcceptChanges();
        }
        catch (Exception ex)
        {


            EventLog LogErr = new EventLog();
            if (!EventLog.SourceExists("WebContrataci"))
            {
                EventLog.CreateEventSource("WebContrataci", "Application");
                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
            }
            else
            {

                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString());
            }
        }
    }

    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            //creamos el objeto tabla para llenar una nueva fila
            DataTable TOut = ds.Tables["Idiomas"];
            DataRow row = TOut.NewRow();
            //ingresamos los datos de la fila
            row["IdIdioma"] = ds.Tables["Idiomas"].Rows.Count + 1;
            row["NombreIdiomas"] = txtOutIdioma.Text;
            row["Nivel"] = txtOutNivel.Text;

            ds.Tables["Idiomas"].Rows.Add(row);

            Outs.Outsourcing cl = new Outs.Outsourcing();
            cl.DatoIdiomas(ds);
            ds.AcceptChanges();
        }
        catch (Exception ex)
        {


            EventLog LogErr = new EventLog();
            if (!EventLog.SourceExists("WebContrataci"))
            {
                EventLog.CreateEventSource("WebContrataci", "Application");
                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
            }
            else
            {

                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString());
            }
        }
    }
    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            //creamos el objeto tabla para llenar una nueva fila
            DataTable TOut = ds.Tables["Areas"];
            DataRow row = TOut.NewRow();
            //ingresamos los datos de la fila
            row["IdArea"] = ds.Tables["Areas"].Rows.Count + 1;
            row["Nombre"] = TxtOutArea.Text;
            row["IdOutsourcing"] = 1;

            ds.Tables["Areas"].Rows.Add(row);

            Outs.Outsourcing cl = new Outs.Outsourcing();
            cl.DatoArea(ds);
            ds.AcceptChanges();
        }
        catch (Exception ex)
        {


            EventLog LogErr = new EventLog();
            if (!EventLog.SourceExists("WebContrataci"))
            {
                EventLog.CreateEventSource("WebContrataci", "Application");
                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString(), EventLogEntryType.Information, 1);
            }
            else
            {

                LogErr.Source = "WebContrataci";
                LogErr.WriteEntry(ex.ToString());
            }
        }
    }
}